if ((the locV of sprite getAt(ppl, i) > the locV of sprite getAt(ppl, i + 1)) and (getAt(ppl, i) < getAt(ppl, i + 1))) or ((the locV of sprite getAt(ppl, i) < the locV of sprite getAt(ppl, i + 1)) and (getAt(ppl, i) > getAt(ppl, i + 1))) then
u = getAt(ppl, i)
setAt(ppl, i, getAt(ppl, i + 1))
setAt(ppl, i + 1, u)
s = sprite(getAt(ppl, i)).flipH
sprite(getAt(ppl, i)).flipH = sprite(getAt(ppl, i + 1)).flipH
sprite(getAt(ppl, i + 1)).flipH = s
x = the loc of sprite getAt(ppl, i)
set the loc of sprite getAt(ppl, i) to the loc of sprite getAt(ppl, i + 1)
set the loc of sprite getAt(ppl, i + 1) to x
x = the member of sprite getAt(ppl, i)
set the member of sprite getAt(ppl, i) to the member of sprite getAt(ppl, i + 1)
set the member of sprite getAt(ppl, i + 1) to x
end if
if ((i + 2) < 5) and (f > 2) then
if ((the locV of sprite getAt(ppl, i) > the locV of sprite getAt(ppl, i + 2)) and (getAt(ppl, i) < getAt(ppl, i + 2))) or ((the locV of sprite getAt(ppl, i) < the locV of sprite getAt(ppl, i + 2)) and (getAt(ppl, i) > getAt(ppl, i + 2))) then
u = getAt(ppl, i)
setAt(ppl, i, getAt(ppl, i + 2))
setAt(ppl, i + 2, u)
s = sprite(getAt(ppl, i)).flipH
sprite(getAt(ppl, i)).flipH = sprite(getAt(ppl, i + 2)).flipH
sprite(getAt(ppl, i + 2)).flipH = s
x = the loc of sprite getAt(ppl, i)
set the loc of sprite getAt(ppl, i) to the loc of sprite getAt(ppl, i + 2)
set the loc of sprite getAt(ppl, i + 2) to x
x = the member of sprite getAt(ppl, i)
set the member of sprite getAt(ppl, i) to the member of sprite getAt(ppl, i + 2)
set the member of sprite getAt(ppl, i + 2) to x
end if
end if
if ((i + 3) < 5) and (f > 2) then
if ((the locV of sprite getAt(ppl, i) > the locV of sprite getAt(ppl, i + 3)) and (getAt(ppl, i) < getAt(ppl, i + 3))) or ((the locV of sprite getAt(ppl, i) < the locV of sprite getAt(ppl, i + 3)) and (getAt(ppl, i) > getAt(ppl, i + 3))) then
u = getAt(ppl, i)
setAt(ppl, i, getAt(ppl, i + 3))
setAt(ppl, i + 3, u)
s = sprite(getAt(ppl, i)).flipH
sprite(getAt(ppl, i)).flipH = sprite(getAt(ppl, i + 3)).flipH
sprite(getAt(ppl, i + 3)).flipH = s
x = the loc of sprite getAt(ppl, i)
set the loc of sprite getAt(ppl, i) to the loc of sprite getAt(ppl, i + 3)
set the loc of sprite getAt(ppl, i + 3) to x
x = the member of sprite getAt(ppl, i)
set the member of sprite getAt(ppl, i) to the member of sprite getAt(ppl, i + 3)
set the member of sprite getAt(ppl, i + 3) to x
end if
end if
end repeat
end
on strata3 f
global ppl
o = [:]
oflip = []
omember = []
oloc = []
repeat with i = 1 to f
addProp(o, the locV of sprite getAt(ppl, i), getAt(ppl, i))
addAt(oflip, i, sprite(getAt(ppl, i)).flipH)
addAt(omember, i, the member of sprite getAt(ppl, i))
addAt(oloc, i, the loc of sprite getAt(ppl, i))
end repeat
sort(o)
ppl2 = duplicate(ppl)
repeat with i = 1 to f
if getAt(ppl, i) <> getAt(o, i) then
x = findPos(ppl, getAt(o, i))
sprite(getAt(ppl, i)).flipH = getAt(oflip, x)
set the loc of sprite getAt(ppl, i) to getAt(oloc, x)
set the member of sprite getAt(ppl, i) to getAt(omember, x)